package com.uenpay.im.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.uenpay.im.R;
import com.uenpay.im.entities.TalkLongClickViewEntity;

import java.util.ArrayList;


/**
 * @author SL
 * @created 2016-2-29 下午4:22:17
 * @copyRight http://www.qiyunxin.com
 * @function 会话页面长按item adapter
 */
public class TalkLongClickViewAdapter extends BaseAdapter {

	private LayoutInflater mLayoutInflater = null;
	public ArrayList<TalkLongClickViewEntity> arrayList = new ArrayList<TalkLongClickViewEntity>();

	public TalkLongClickViewAdapter(Context _Context,
			ArrayList<TalkLongClickViewEntity> _arrayList) {
		arrayList = _arrayList;
		mLayoutInflater = LayoutInflater.from(_Context);
	}

	@Override
	public int getCount() {
		return arrayList == null ? 0 : arrayList.size();
	}

	@Override
	public Object getItem(int arg0) {
		return arrayList == null ? null : arrayList.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		TalkLongClickViewHodler clickViewHodler = null;
		TalkLongClickViewEntity mTalkLongClickViewEntity = arrayList.get(arg0);
		if (arg1 == null) {
			clickViewHodler = new TalkLongClickViewHodler();
			arg1 = mLayoutInflater.inflate(
					R.layout.custom_contenxt_menu_item, null);
			clickViewHodler.name_textview = (TextView) arg1.findViewById(R.id.type_name);
			arg1.setTag(clickViewHodler);
		} else {
			clickViewHodler = (TalkLongClickViewHodler) arg1.getTag();
		}

		clickViewHodler.name_textview
				.setText(mTalkLongClickViewEntity.resourceId);
		return arg1;
	}

	private class TalkLongClickViewHodler {
		private TextView name_textview;
	}

}
